﻿function ReasonVisible(actionName) {
    if ($('#<%=btnDeactivate.ClientID%>').val() == "Deactivate") {
        if ($('#<%=lblReason.ClientID%>').css('visibility') == 'hidden') {
            $('#<%=lblReason.ClientID%>').css('visibility', 'visible');
            $('#<%=txtReason.ClientID%>').css('visibility', 'visible');
            return false;
        }
        else if ($('#<%=txtReason.ClientID%>').val() == '') {
            $('#<%=lblReasonValidation.ClientID%>').css('visibility', 'visible');
            $('#<%=lblReasonValidation.ClientID%>').text('Please enter the reason for ' + actionName);
            return false;
        }
    }

    if ($('#<%=btnDeny.ClientID%>').val() == "Deny") {
        if ($('#<%=lblReason.ClientID%>').css('visibility') == 'hidden') {
            $('#<%=lblReason.ClientID%>').css('visibility', 'visible');
            $('#<%=txtReason.ClientID%>').css('visibility', 'visible');
            return false;
        }
        else if ($('#<%=txtReason.ClientID%>').val() == '') {
            $('#<%=lblReasonValidation.ClientID%>').css('visibility', 'visible');
            $('#<%=lblReasonValidation.ClientID%>').text('Please enter the reason for ' + actionName);
            return false;
        }
    }

    return true;
}

function ValidatePage() {
    if (ValidatePermanentAddressEdit() && ValidatePresentAddressEdit()) {
        return true;
    }
    else {
        return false;
    }
}

function ValidatePermanentAddressEdit() {
    if ($("#<%=pnlPermanentAddressEdit.ClientID%>").data("changed")) {

        if ($("[id*='ucPermanentAddress_FlupldElectricitybill']").val() == "") {
            $("[id*='ucPermanentAddress_lblValidation']").css('visibility', 'visible');
            return false;
        }
    }

    if ($("[id*='ucPermanentAddress_txtAddress']").val() != "") {
        if ($("[id*='ucPermanentAddress_txtPIN']").val() == "") {
            $("[id*='ucPermanentAddress_lblPinValidation']").css('visibility', 'visible');
            return false;
        }
        $("[id*='ucPermanentAddress_lblPinValidation']").css('visibility', 'hidden');
        if ($("[id*='ucPermanentAddress_txtCity']").val() == "") {
            $("[id*='ucPermanentAddress_lblCityValidation']").css('visibility', 'visible');
            return false;
        }
        $("[id*='ucPermanentAddress_lblCityValidation']").css('visibility', 'hidden');
        if ($("[id*='ucPermanentAddress_ddlStateName']").val() == 0 || $("[id*='ucPermanentAddress_ddlStateName']").val() == null) {
            $("[id*='ucPermanentAddress_lblStateValidation']").css('visibility', 'visible');
            return false;
        }
        $("[id*='ucPermanentAddress_lblStateValidation']").css('visibility', 'hidden');
        if ($("[id*='ucPermanentAddress_ddlDistrictName']").val() == 0 || $("[id*='ucPermanentAddress_ddlStateName']").val() == null) {
            $("[id*='ucPermanentAddress_lblDistrictValidation']").css('visibility', 'visible');
            return false;
        }
        $("[id*='ucPermanentAddress_lblDistrictValidation']").css('visibility', 'hidden');
    }
    return true;
}

function ValidatePresentAddressEdit() {
    if ($("#<%=pnlPresentAddressEdit.ClientID%>").data("changed")) {

        if ($("[id*='ucPresentAddress_FlupldElectricitybill']").val() == "") {
            $("[id*='ucPresentAddress_lblValidation']").css('visibility', 'visible');
            return false;
        }
    }
    if ($("[id*='ucPresentAddress_txtAddress']").val() != "") {
        if ($("[id*='ucPresentAddress_txtPIN']").val() == "") {
            $("[id*='ucPresentAddress_lblPinValidation']").css('visibility', 'visible');
            return false;
        }
        $("[id*='ucPresentAddress_lblPinValidation']").css('visibility', 'hidden');
        if ($("[id*='ucPresentAddress_txtCity']").val() == "") {
            $("[id*='ucPresentAddress_lblCityValidation']").css('visibility', 'visible');
            return false;
        }
        $("[id*='ucPresentAddress_lblCityValidation']").css('visibility', 'hidden');
        if ($("[id*='ucPresentAddress_ddlStateName']").val() == 0 || $("[id*='ucPresentAddress_ddlStateName']").val() == null) {
            $("[id*='ucPresentAddress_lblStateValidation']").css('visibility', 'visible');
            return false;
        }
        $("[id*='ucPresentAddress_lblStateValidation']").css('visibility', 'hidden');
        if ($("[id*='ucPresentAddress_ddlDistrictName']").val() == 0 || $("[id*='ucPresentAddress_ddlStateName']").val() == null) {
            $("[id*='ucPresentAddress_lblDistrictValidation']").css('visibility', 'visible');
            return false;
        }
        $("[id*='ucPresentAddress_lblDistrictValidation']").css('visibility', 'hidden');
    }
    return true;
}